global infile "DataMain.dta"
global outfile "$results/Table 3"


* Table 3A. Before-after estimates

use "$infile", clear 
keep if treated == 1
xtreg logwater treat i.moy, fe i(home) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word replace ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear 
keep if treated == 1 & dataset == 1
xtreg logwater treat i.moy, fe i(home) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear 
keep if treated == 1 & dataset == 2
xtreg logwater treat i.moy, fe i(home) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear 
keep if treated == 1 & dataset == 3
xtreg logwater treat i.moy, fe i(home) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 


* Table 3B. Diff-in-diff estimates

use "$infile", clear
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear
keep if dataset == 1
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear
keep if dataset == 2
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 

use "$infile", clear
keep if dataset == 3
reghdfe logwater treat, absorb(datasethome datasetweek) cluster(home)
leveleffects
outreg2 using "$outfile", keep(treat) nocon 2aster dec(3) word ap ///
addstat(pre, $prem, effect, $effectm, transbeta, $transbeta) 
